package com.cainiaoshixi.admin.service.Impl;/**
 * Created by Administrator on 2018/1/30.
 */

import com.cainiaoshixi.admin.dao.CompanyEmailsMapper;
import com.cainiaoshixi.admin.dao.JobMapper;
import com.cainiaoshixi.admin.entity.CompanyEmails;
import com.cainiaoshixi.admin.entity.JobWithBLOBs;
import com.cainiaoshixi.admin.service.IJobService;
import com.cainiaoshixi.admin.vo.JobQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:陈汉宇
 * @Description:
 * @Date: Created in 16:10 2018/1/30
 * @Modified By:
 */
@Service
public class JobServiceImpl implements IJobService {
    @Autowired
    private JobMapper jobMapper;

    @Autowired
    private CompanyEmailsMapper companyEmailsMapper;

    public List<JobWithBLOBs> getJobListByVo(JobQueryVo jobQueryVo) {
        return jobMapper.getJobListByVo(jobQueryVo);
    }

    public int getJobCountByBo(JobQueryVo jobQueryVo) {
        return jobMapper.getJobCountByBo(jobQueryVo);
    }

    public JobWithBLOBs selectByPrimaryKey(Long id) {
        return jobMapper.selectByPrimaryKey(id);
    }

    public int updateById(JobWithBLOBs jobWithBLOBs) {
        return jobMapper.updateByPrimaryKeySelective(jobWithBLOBs);
    }

    public void insertJob(JobWithBLOBs jobWithBLOBs) {
        jobMapper.insertSelective(jobWithBLOBs);
    }

    public int getEmailCountByEmail(CompanyEmails companyEmails) {
        return companyEmailsMapper.getEmailsCountByEmail(companyEmails);
    }

    public void insertEmail(CompanyEmails companyEmails) {
        if(companyEmails.getSendCount() == null ){
            companyEmails.setSendCount(1);
        } else {
            companyEmails.setSendCount(companyEmails.getSendCount()+1);
        }
        companyEmailsMapper.insertSelective(companyEmails);
    }
}
